package com.naja.auth2server.web.dto;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.security.oauth2.server.authorization.util.SpringAuthorizationServerVersion;

import java.io.Serializable;
import java.time.Instant;
import java.util.Map;
import java.util.Set;

/**
 * @auther wangjianying
 * @date 2023/12/14 14:17
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RegisteredClientDto implements Serializable {
    private static final long serialVersionUID = SpringAuthorizationServerVersion.SERIAL_VERSION_UID;
    private String id;
    private String clientId;
    private Instant clientIdIssuedAt;
    private String clientSecret;
    private Instant clientSecretExpiresAt;
    private String clientName;
    private Set<Map<String,Object>> clientAuthenticationMethods;
    private Set<Map<String,Object>> authorizationGrantTypes;
    private Set<String> redirectUris;
    private Set<String> scopes;
    private Map<String,Map> clientSettings;
    private Map<String,Map> tokenSettings;


    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
        String json = "{\n" +
                "    \"id\":\"jelfjieiojfljfeljfoeifjoewfkhfiehfijeofjoef\",\n" +
                "  \"clientId\": \"camunda-server\"\n" +
                "  \n" +
                "}";
        RegisteredClientDto registeredClientDto = objectMapper.readValue(json, RegisteredClientDto.class);
        String rs = objectMapper.writeValueAsString(registeredClientDto);
        System.out.println(rs);


    }
}
